<?php
namespace UserForm\Model;
class User
{
   public $id;
   public $name;
   public $email;
   public $password;
   public $education;
   public $sex;
   public $contact;
   public $homepage;
   public $hobby;
   public $introduction;
   public function setPassword($clear_password)
   {
     $this->password = md5($clear_password);
   }
   public function exchangeArray($data)         //多态,继承了ArrayObject全局对象的exchangeArray($data)方法
   {
      $this->name =(isset($data['name'])) ? $data['name']:null;
      $this->email=(isset($data['email']))? $data['email']:null;
      $this->education =(isset($data['education'])) ? $data['education']:null;
      $this->sex =(isset($data['sex'])) ? $data['sex']:null;
      $this->contact =(isset($data['contact'])) ? $data['contact']:null;
      $this->homepage =(isset($data['homepage'])) ? $data['homepage']:null;
      $this->hobby =(isset($data['hobby'])) ? $data['hobby']:null;
      $this->introduction =(isset($data['introduction'])) ? $data['introduction']:null;
      if(isset($data["password"]))
      {
        $this->setPassword($data["password"]);
      }
   }
}

